import { VideoMaterial, AudioMaterial, TextMaterial, StickerMaterial } from './Material';

export interface Segment {
  materialId: string;
  targetTimerange: {
    start: number; // microseconds
    duration: number;
  };
  sourceTimerange?: {
    start: number;
    duration: number;
  };
  speed?: number;
  rotation?: number;
  opacity?: number;
  scale?: number;
  position?: {
    x: number;
    y: number;
  };
  effect?: {
    name: string;
    params: Record<string, any>;
  };
}

// 类型安全的Segment工厂
export function createVideoSegment(
  materialId: string,
  start: number,
  duration: number,
  sourceStart?: number,
  sourceDuration?: number
): Segment {
  return {
    materialId,
    targetTimerange: { start, duration },
    sourceTimerange: sourceStart && sourceDuration ? { start: sourceStart, duration: sourceDuration } : undefined
  };
}

export function createAudioSegment(
  materialId: string,
  start: number,
  duration: number
): Segment {
  return {
    materialId,
    targetTimerange: { start, duration }
  };
}
